﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Engine.Dtd.Schema;
using Engine.Sgml.Assembling;
using System.Diagnostics;

namespace Engine.Sgml.Matching {
    internal static class ElementMatcher {
        public static bool Match(SElement element, IModelGroupsNode item) {
            return item.Name == element.DName;
            }

        public static bool Match(SObject element, SObject other) {
            Debug.Assert(element != null);
            Debug.Assert(other != null);
            if (element.Name == other.Name)
                return true;
            if (object.ReferenceEquals(element.DName, null) &&
                object.ReferenceEquals(other.DName, null))
                return string.Equals(element.LocalName, other.LocalName, StringComparison.Ordinal) &&
                       string.Equals(element.Prefix, other.Prefix, StringComparison.Ordinal);
            return element.DName == other.DName;
            }

        /// <summary>
        /// Indicating whether the element was built by an assembler.
        /// </summary>
        /// <param name="element">An element object.</param>
        /// <returns>true if an element was built; otherwise, false.</returns>
        public static bool IsCunstructedElement(SElement element) {
            return element.NodeType == SgmlNodeType.Text && object.ReferenceEquals(element.Value, ElementAssembler.DefaultElementValue);
            }
        }
    }
